{% extends "layout.html" %}

{% block title %}
<title>{{ post.title }}</title>
{% endblock %}

{% block boxies %}
{% endblock %}

{% block main %}
<div class="sep20"></div>
<div class="box" style="border-bottom: 0px;">
    <div class="header"><div class="fr"><a href="/member/{{ post.author.name }}"><img src="{{ post.author.avatar }}" class="avatar" border="0" align="default"></a></div>
    <a href="/">V2EX</a> <span class="chevron">&nbsp;›&nbsp;</span> <a href="/go/webmaster">站长</a>
    <div class="sep10"></div>
    <h1>{{ post.title }}</h1>
    <div id="topic_357368_votes" class="votes">
<a href="javascript:" onclick="upVoteTopic(357368);" class="vote"><li class="fa fa-chevron-up"></li></a> &nbsp;<a href="javascript:" onclick="downVoteTopic(357368);" class="vote"><li class="fa fa-chevron-down"></li></a></div> &nbsp; <small class="gray"><a href="/member/{{ post.author.name }}">{{ post.author.name }}</a> · {{ post.pub_date|dateformat }} · {{ post.views }} 次点击 &nbsp; </small>
    </div>



    <div class="cell">

        <div class="topic_content">{{ post.content|safe }}</div>
        <script>hljs.initHighlightingOnLoad();</script>

    </div>

    {% if post.subtle %}
    <div class="subtle">
        <span class="fade">第 1 条附言 &nbsp;·&nbsp; 3 小时 46 分钟前</span>
        <div class="sep5"></div>

        <div class="topic_content">扒了一下这个网站，特别有意思：
    }
<br><a target="_blank" href="http://weibo.com/ttarticle/p/show?id=2309404100680607514768" rel="nofollow">http://weibo.com/ttarticle/p/show?id=2309404100680607514768</a></div>

    </div>
    {% endif %}

    <div class="topic_buttons"><div class="fr gray f11" style="line-height: 12px; padding-top: 3px; text-shadow: 0px 1px 0px #fff;">{{ post.views }} 次点击 &nbsp;∙&nbsp; {{ post.collected_count }} 人收藏 &nbsp; </div><a href="/favorite/topic/{{ post.id }}?t=ecxoyxcxhuwvbdmdimspvuaordtvbpjj" class="tb">加入收藏</a> &nbsp;<a href="#;" onclick="window.open('https://twitter.com/share?url=https://www.v2ex.com/t/{{ post.id }}?r\u003Dyuansmin&amp;related=v2ex&amp;hashtags=webmaster&amp;text={{ (post.content|striptags)[:20] }}', '_blank', 'width=550,height=370'); recordOutboundLink(this, 'Share', 'twitter.com');" class="tb">Tweet</a> &nbsp;<a href="#;" onclick="window.open('http://service.weibo.com/share/share.php?url=https://www.v2ex.com/t/{{ post.id }}?r\u003Dyuansmin&amp;title=V2EX%20-%20{{ (post.content|striptags)[:20] }}', '_blank', 'width=550,height=370'); recordOutboundLink(this, 'Share', 'weibo.com');" class="tb">Weibo</a> &nbsp;<a href="#;" onclick="if (confirm('确定不想再看到这个主题？')) { location.href = '/ignore/topic/{{ post.id }}?once=40306'; }" class="tb">忽略主题</a> &nbsp;<div id="topic_thank"><a href="#;" onclick="if (confirm('你确定要向本主题创建者发送谢意？')) { thankTopic({{ post.id }}, 'ecxoyxcxhuwvbdmdimspvuaordtvbpjj'); }" class="tb">感谢</a></div></div>
</div>

<div class="sep20"></div>

{% if not post.comment_count %}
<div class="box transparent">
    <div class="inner" style="text-align: center">
        <span style="color: rgba(0, 0, 0, 0.25);">目前尚无回复</span>
    </div>
</div>
<div class="sep20"></div>
<div class="box">
<div class="inner"><a href="/tag/fcitx" class="tag">fcitx</a><a href="/tag/菜单" class="tag">菜单</a><a href="/tag/1.18.0" class="tag">1.18.0</a><a href="/tag/log" class="tag">log</a></div>
</div>
{% else %}
<div id="comment" class="box">
<div class="cell"><div class="fr" style="margin: -3px -5px 0px 0px;"><a href="/tag/MySQL" class="tag"><li class="fa fa-tag"></li> MySQL</a><a href="/tag/容器" class="tag"><li class="fa fa-tag"></li> 容器</a><a href="/tag/Docker" class="tag"><li class="fa fa-tag"></li> Docker</a><a href="/tag/进程" class="tag"><li class="fa fa-tag"></li> 进程</a></div><span class="gray">{{ post.comment_count }} 回复 &nbsp;<strong class="snow">|</strong> &nbsp;直到 {{ now }}</span>
    </div>

{% if post.comment_count > 50 %}
<div class="cell">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tbody><tr>
            <td width="92%" align="left">
            {% for i in page_list %}
                {% if i > 0 %}
                    {% if i == paginate.page %}
                    <a href="?p={{ i }}" class="page_current">{{ i }}</a> &nbsp; #}
                    {% else %}
                    <a href="?p={{ i }}" class="page_normal">{{ i }}</a> &nbsp;
                    {% endif %}

                {% else %}
                    <span class="fade"> ... </span>
                {% endif %}
            {% endfor %}
            {# <a href="?p=2" class="page_current">2</a> &nbsp; #} <input type="number" class="page_input" autocomplete="off" value="" min="1" max="{{ page_list[-1] }}" onkeydown="if (event.keyCode == 13)
                    location.href = '?p=' + this.value">
            </td>
            <td width="8%" align="right">
                <table cellpadding="0" cellspacing="0" border="0" width="100%">
                    <style type="text/css">
                        .disable_now {
                            color: #ccc !important;
                            background-color: #fff !important;
                        }
                        .hover_now {
                            cursor: pointer;
                            color: #333 !important;
                            background-color: #f9f9f9 !important;
                            text-shadow: 0px 1px 0px #fff !important;
                        }
                        .active_now {
                            background-color: #e2e2e2 !important;
                        }
                    </style>
                    <tbody><tr>
                        <td width="50%" align="center" class="super normal button" style="border-right: none; border-top-right-radius: 0px; border-bottom-right-radius: 0px;" onclick="location.href='?p=1';" onmouseover="$(this).addClass('hover_now');" onmousedown="$(this).addClass('active_now');" onmouseleave="$(this).removeClass('hover_now'); $(this).removeClass('active_now');" title="上一页">❮</td>
                        <td width="50%" align="center" class="super normal_page_right button disable_now" style="border-top-left-radius: 0px; border-bottom-left-radius: 0px;">❯</td>
                    </tr>
                </tbody></table>
            </td>
        </tr>
    </tbody></table>
</div>
{% endif %}

{% for comment in comments %}
<div id="r_{{ comment.id }}" class="cell">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tbody><tr>
        <td width="48" valign="top" align="center"><img src="{{ comment.author.avatar }}" class="avatar" border="0" align="default"></td>
        <td width="10" valign="top"></td>
        <td width="auto" valign="top" align="left"><div class="fr"><div id="thank_area_4263970" class="thank_area"><a href="#;" onclick="if (confirm('确认要不再显示来自 @Parabola 的这条回复？')) { ignoreReply(4263970, '40306'); }" class="thank" style="color: #ccc;">隐藏</a> &nbsp; &nbsp; &nbsp; <a href="#;" onclick="if (confirm('确认花费 10 个铜币向 @Parabola 的这条回复发送感谢？')) { thankReply(4263970, 'eyajytxwqawwwdmgoyhnltwmvworakpf'); }" class="thank">感谢回复者</a></div> &nbsp; <a href="#;" onclick="replyOne('Parabola');"><img src="//cdn.v2ex.com/static/img/reply.png" align="absmiddle" border="0" alt="Reply"></a> &nbsp;&nbsp; <span class="no">{{ loop.index }}</span></div>
            <div class="sep3"></div>
            <strong><a href="/member/{{ comment.author.name }}" class="dark">{{ comment.author.name }}</a></strong>&nbsp; &nbsp;<span class="fade small">{{ comment.pub_date|dateformat }}</span>
            <div class="sep5"></div>
            <div class="reply_content">{{ comment.content|safe }}</div>
        </td>
    </tr>
</tbody></table>
</div>
{% endfor %}
</div>

{% endif %}
<div class="sep20"></div>
<div class="box">
    <div class="cell"><div class="fr"><a href="#" onclick="goTop()"><strong>↑</strong> 回到顶部</a></div>
        添加一条新回复
    </div>
    <div class="cell"><form method="post" action="/addComment">
        <textarea name="content" maxlength="10000" class="mll" id="reply_content" style="overflow: hidden; word-wrap: break-word; resize: none; height: 112px;"></textarea>
        <div class="sep10"></div>
        <div class="fr"><div class="sep5"></div><span class="gray">请尽量让自己的回复能够对别人有帮助</span></div>
        <input type="hidden" value="{{ post.id }}" name="post_id">
        <input type="submit" name="" value="回复">
        {# <a id="submit" class="super normal button" style="cursor:pointer">回复</a> #}
        <script type="text/javascript">
        $("#reply_content").on('input', function(e) {
            saveReplyDraft({{ post.id }}, 211484);
        });
        var post_id = {{ post.id }};
        var user = {
            id: {{ current_user.id }},
            name: "{{ current_user.name }}",
            avatar: "{{ current_user.avatar }}",
        };
        // $("#submit").on('click', function(){
        //     var content = $("#reply_content").val();
        //     if (content.length <= 0) {
        //         alert("请输入评论内容!");
        //         return;
        //     }
        //     $.ajax({
        //         data: {'post_id': post_id, 'content': content},
        //         url: '/addComment',
        //         type: 'post',
        //         success: function(res) {
        //             console.log(res);
        //             render_comment(content, res.comment_id);
        //         },
        //         error: function(err) {
        //             alert('err' + err);
        //         },
        //     })
        // });

        function render_comment(content, comment_id) {
            var html = '<div id="r_'+comment_id+'" class="cell">\
<table cellpadding="0" cellspacing="0" border="0" width="100%">\
    <tbody><tr>\
        <td width="48" valign="top" align="center"><img src="'+ user.avatar +'" class="avatar" border="0" align="default"></td>\
        <td width="10" valign="top"></td>\
        <td width="auto" valign="top" align="left"><div class="fr"><div id="thank_area_'+comment_id+'" class="thank_area"><a href="#;" onclick="if (confirm("确认要不再显示来自 @Parabola 的这条回复？")) { ignoreReply(4263970, "40306"); }" class="thank" style="color: #ccc;">隐藏</a> &nbsp; &nbsp; &nbsp; <a href="#;" onclick="if (confirm("确认花费 10 个铜币向 @Parabola 的这条回复发送感谢？")) { thankReply(4263970, "eyajytxwqawwwdmgoyhnltwmvworakpf"); }" class="thank">感谢回复者</a></div> &nbsp; <a href="#;" onclick="replyOne("Parabola");"><img src="//cdn.v2ex.com/static/img/reply.png" align="absmiddle" border="0" alt="Reply"></a> &nbsp;&nbsp; <span class="no"></span></div>\
            <div class="sep3"></div>\
            <strong><a href="/member/'+ user.name + '" class="dark">' + user.name + '</a></strong>&nbsp; &nbsp;<span class="fade small">刚刚</span>\
            <div class="sep5"></div>\
            <div class="reply_content">'+content+'</div>\
        </td>\
    </tr>\
</tbody></table>\
</div>';
        $("#comment").append(html);
        }

        var keyPressed = 0;

        $("#reply_content").keydown(function(e) {
            keyPressed = keyPressed + 1;

            if ((e.ctrlKey || e.metaKey) && e.which === 13) {
                e.preventDefault();
                $("#reply_content").parent().submit();
            }
        });
        </script>
    </div>
    <div class="inner">
        <div class="fr"><a href="/">← V2EX</a></div>
        &nbsp;
    </div>
</div>

{% endblock %}